﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace kwzx
{
    public partial class frmScmShow : Form
    {
        public frmScmShow()
        {
            InitializeComponent();
        }


        public Uri uri;
        private HtmlElementEventHandler HtmlBtnClose_Click;
      
        private void frmScmShow_Load(object sender, EventArgs e)
        {
            this.webBrowser1.Navigate(uri);
         
        }


        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            ////自动点击弹出确认或弹出提示
            //IHTMLDocument2 vDocument = (IHTMLDocument2)webBrowser1.Document.DomDocument;
            //vDocument.parentWindow.execScript("function confirm(str){return true;} ", "javascript"); //弹出确认
            //vDocument.parentWindow.execScript("function alert(str){return true;} ", "javaScript");//弹出提示
            ////下面是你的执行操作代码


            HtmlDocument htmlDoc = webBrowser1.Document;
            HtmlElement btnElement = htmlDoc.All["bt_cancle"];
            if (btnElement != null)
            {
                btnElement.Click += new HtmlElementEventHandler(HtmlBtnClose_Click);
            } 
        }

        private void frmScmShow_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.webBrowser1.Dispose();
            //在单击该窗体上的按钮时触发事件
            if (myevent != null)
            {
                myevent(true);
            }
        }


        public delegate void mydelegate(bool text);//定义一个委托
        public event mydelegate myevent;//定义上诉委托类型的事件
        private void frmScmShow_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                frmScmShow_FormClosed(null, null);
            }
        }


         
    }
}
